import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        //  城市信息
        location: {
            name: "北京",
            id: "101010100",
            adm2: "北京",
            adm1: "北京"
        },
        //    24 小时天气
        hourly: {
            fxTime: [],
            temp: []
        }
    },
    getters: {
        getLocation(state) {
            return state.location
        }
    },
    mutations: {
        updateHourly({hourly}, hourData) {
            Object.assign(hourly, hourData)
        },
        updateLocation(state, newLocation) {
            state.location = newLocation
            // Object.assign(location, newLocation)
        }
    },
    actions: {
        updateHourlyActions({commit}, hourData) {
            commit("updateHourly", hourData)
        },
        updateLocationAction({commit}, newLocation) {
            commit("updateLocation", newLocation)
        }
    },
    modules: {}
})
